package com.gshg.log.cleanlog.quartz.demo;

import org.quartz.*;

//@Configuration
public class QuartzJobRunConfigure {

//    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(JobDetailDemo1.class)//需要修改
                .withIdentity("jobDetailDemo1")//需要修改
                .storeDurably().build();
    }

    // 把jobDetail注册到Cron表达式的trigger上去
//    @Bean
    public Trigger JobDetail1JobTrigger() {
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0 */2 * * * ?"); //需要修改，可使用yaml配置

        return TriggerBuilder.newTrigger()
                .forJob(jobDetail())   //需要修改
                .withIdentity("JobDetail1JobTrigger")
                .withSchedule(cronScheduleBuilder)
                .build();
    }



 ///----分界线---------------------------------------------------------------------------

//    @Bean
    public JobDetail jobDetai2() {
        JobDataMap jobDataMap = new JobDataMap();//设置初始参数
        jobDataMap.put("count", 10000);
        return JobBuilder.newJob(JobDetailDemo2.class) //需要修改
                .withIdentity("jobDetailDemo2")//需要修改
                .setJobData(jobDataMap)
                .storeDurably().build();
    }

    // 把jobDetail注册到Cron表达式的trigger上去
//    @Bean
    public Trigger JobDetail2JobTrigger() {
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0 */3 * * * ?");//需要修改，可使用yaml配置
        return TriggerBuilder.newTrigger()
                .forJob(jobDetai2())  //需要修改
                .withIdentity("JobDetail2JobTrigger")//需要修改
                .withSchedule(cronScheduleBuilder)
                .build();
    }

}

///----分界线---------------------------------------------------------------------------
